#include "map_object.h"
#include <stdlib.h>

void map_object_init (MapObject* map_object, MapObjectType type)
{
	map_object->type = type;
	
	map_object->px_x = 0;
	map_object->px_y = 0;
	map_object->move_x = 0;
	map_object->move_y = 0;
	
	map_object->orientation = DIR_NONE;
	map_object->image = 0;
	map_object->state = 0;
	
	// map_object->coord and index remain unchanged because it is first set
	// by map_add_object, before the caller calls init or make_*.
}

void map_object_make_obstacle (MapObject* map_object)
{
	map_object_init (map_object, OBJ_OBSTACLE);
}

void map_object_make_treasure_gold (MapObject* map_object, TreasureGoldObject treasure)
{
	map_object_init (map_object, OBJ_TREASURE_GOLD);
	map_object->treasure_gold = treasure;
}

void map_object_make_treasure_item (MapObject* map_object, TreasureItemObject treasure)
{
	map_object_init (map_object, OBJ_TREASURE_ITEM);
	map_object->treasure_item = treasure;
}

void map_object_make_lever (MapObject* map_object, Coord target)
{
	map_object_init (map_object, OBJ_LEVER);
	map_object->lever.target = target;
}

void map_object_make_sokobox (MapObject* map_object)
{
	map_object_init (map_object, OBJ_SOKOBOX);
}
